package com.xuetang9.fujian.donamicproxy.automachine;

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @author: fujian
 * @description: 自实现的幸运售货机
 * @date: 2021/5/1 10:46
 * @version: V1.0
 * @package: com.xuetang9.fujian.donamicproxy.automachine
 **/
@SuppressWarnings("all")
public class LuckVedingMachine implements IVendingMachine{
    Queue<String> goods = new ArrayDeque<String>();

    public LuckVedingMachine() {
        // 模拟自动售货机的进货
        goods.offer("1");
        goods.offer("2");
        goods.offer("3");
        goods.offer("4");
        goods.offer("5");
        goods.offer("6");
    }

    @Override
    public boolean transaction(int money) {
//        假设用户钱够
        System.out.println("用户投币：" + money + "元");
        if (goods.size() != 0){
            System.out.println("商家入账：" + money +"元");
            return true;
        }
        return false;
    }

    @Override
    public void shipment() {
        System.out.println(goods.poll() + "出货");
    }
}
